import Page
from Page import Bluetoothphone
from Base.Base import Base
from selenium.webdriver.common.by import By


class BluetoothphonelIndexPage(Base):
    """
    蓝牙电话首页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.phone_home_btn = (By.XPATH, Bluetoothphone.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.phone_back_btn = (By.XPATH, Bluetoothphone.RESOURCE_ID.format('ivBack'))

        # 关闭弹窗按钮
        self.phone_close_btn = (By.XPATH, Bluetoothphone.RESOURCE_ID.format("bt_back"))

        # 通话记录按钮
        self.phone_call_records_btn = (By.XPATH, Bluetoothphone.RESOURCE_ID.format("rb_record"))

        # 拨号按钮
        self.phone_number_book_btn = (By.XPATH, Bluetoothphone.RESOURCE_ID.format("rb_keypad"))

        # 联系人按钮
        self.phone_contact_person_btn = (By.XPATH, Bluetoothphone.RESOURCE_ID.format("rb_contacts"))

        # 同步按钮
        self.phone_synchronize_btn = (By.XPATH, Bluetoothphone.RESOURCE_ID.format("bt_refresh"))

        # 未连接图片
        self.phone_no_connect_img = (By.XPATH, Bluetoothphone.not_connected_img.format(""))

        # 未连接文案
        self.phone_no_connect_tip_text = (By.XPATH, Bluetoothphone.not_connected_text.format(""))

        # 去连接按钮
        self.phone_go_connect_btn = (By.XPATH, Bluetoothphone.RESOURCE_ID.format("iv_connect_setting"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.phone_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.phone_back_btn)

    def click_close(self):
        """
        点击关闭按钮

        :return:None
        """
        self.click_element(self.phone_close_btn)

    def click_call_records(self):
        """
        点击通话记录按钮

        :return:None
        """
        self.click_element(self.phone_call_records_btn)

    def click_number_book(self):
        """
        点击拨号按钮

        :return:None
        """
        self.click_element(self.phone_number_book_btn)

    def click_contact_person(self):
        """
        点击联系人按钮

        :return:None
        """
        self.click_element(self.phone_contact_person_btn)

    def click_synchronize(self):
        """
        点击同步按钮

        :return:None
        """
        self.click_element(self.phone_synchronize_btn)

    def click_go_connect(self):
        """
        点击去连接按钮

        :return:None
        """
        self.click_element(self.phone_go_connect_btn)

    def get_no_connect(self, index=1):
        """
        获取未连接图片

        :return:获取元素
        """
        self.phone_no_connect_img = (By.XPATH, Bluetoothphone.not_connected_img.format(index))
        return self.find_element_o(self.phone_no_connect_img)

    def get_no_connect_tip(self, index=1):
        """
        获取未连接文案

        :return:获取元素
        """
        self.phone_no_connect_img = (By.XPATH, Bluetoothphone.not_connected_img.format(index))
        return self.find_element_o(self.phone_no_connect_tip_text)

    def is_display_bluetoothphone_index(self):
        """
        查看是否进入蓝牙电话首页

        :return:
        """
        return self.is_display(self.phone_call_records_btn)
